<?php

include_once("../controlador/GestorTelefono.php");
$gestor = new GestorTelefono();
$fono = $_REQUEST["telefono"];
$callback = $_REQUEST["callback"];
$maxRows = $_REQUEST["maxRows"];
$a = $gestor->buscarTelefono($fono,$maxRows);
$result=$a["result"];
$contador = $a["conteo"];

$data =array();

while ($row = $result->fetch_assoc()) {
    $val1 = $row["idfono"];
    $val2 = $row["fono"];
    $data[] = '{"id":"' . $val1 . '", "fono":"' . $val2 . '"}';
}

echo $callback;
echo '({
    "totalResultsCount":' . $contador . ',
     "telefonos":[
';
echo implode($data,",");
echo '
     ]
});';
?>